package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysPeixuanjian;
import com.ruoyi.system.service.ISysPeixuanjianService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 配选件Controller
 * 
 * @author ruoyi
 * @date 2020-12-13
 */
@Controller
@RequestMapping("/system/peixuanjian")
public class SysPeixuanjianController extends BaseController
{
    private String prefix = "system/peixuanjian";

    @Autowired
    private ISysPeixuanjianService sysPeixuanjianService;

    @RequiresPermissions("system:peixuanjian:view")
    @GetMapping()
    public String peixuanjian()
    {
        return prefix + "/peixuanjian";
    }

    /**
     * 查询配选件列表
     */
    @RequiresPermissions("system:peixuanjian:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysPeixuanjian sysPeixuanjian)
    {
        startPage();
        List<SysPeixuanjian> list = sysPeixuanjianService.selectSysPeixuanjianList(sysPeixuanjian);
        return getDataTable(list);
    }

    /**
     * 导出配选件列表
     */
    @RequiresPermissions("system:peixuanjian:export")
    @Log(title = "配选件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysPeixuanjian sysPeixuanjian)
    {
        List<SysPeixuanjian> list = sysPeixuanjianService.selectSysPeixuanjianList(sysPeixuanjian);
        ExcelUtil<SysPeixuanjian> util = new ExcelUtil<SysPeixuanjian>(SysPeixuanjian.class);
        return util.exportExcel(list, "peixuanjian");
    }

    /**
     * 新增配选件
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存配选件
     */
    @RequiresPermissions("system:peixuanjian:add")
    @Log(title = "配选件", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysPeixuanjian sysPeixuanjian)
    {
        return toAjax(sysPeixuanjianService.insertSysPeixuanjian(sysPeixuanjian));
    }

    /**
     * 修改配选件
     */
    @GetMapping("/edit/{peiXuanJianId}")
    public String edit(@PathVariable("peiXuanJianId") Long peiXuanJianId, ModelMap mmap)
    {
        SysPeixuanjian sysPeixuanjian = sysPeixuanjianService.selectSysPeixuanjianById(peiXuanJianId);
        mmap.put("sysPeixuanjian", sysPeixuanjian);
        return prefix + "/edit";
    }

    /**
     * 修改保存配选件
     */
    @RequiresPermissions("system:peixuanjian:edit")
    @Log(title = "配选件", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysPeixuanjian sysPeixuanjian)
    {
        return toAjax(sysPeixuanjianService.updateSysPeixuanjian(sysPeixuanjian));
    }

    /**
     * 删除配选件
     */
    @RequiresPermissions("system:peixuanjian:remove")
    @Log(title = "配选件", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysPeixuanjianService.deleteSysPeixuanjianByIds(ids));
    }
}
